<template>
  <div>
    <!-- <a-button type="primary" @click="showModal">Open Modal with async logic</a-button> -->
    <a-modal v-model:visible="open" title="编辑" @ok="handleOk">
      <a-form>
        <a-form-item label="日期">
          <a-input :placeholder="yearMonth" />
        </a-form-item>
        <a-form-item label="类型">
          <a-radio-group v-model:value="value">
            <a-radio :value="true">休</a-radio>
            <a-radio :value="false">工</a-radio>
          </a-radio-group>
        </a-form-item>
      </a-form>
    </a-modal>
  </div>
</template>
<script lang="ts" setup>
import { ref } from 'vue';
import Holidayapi from '@/api/Holidayapi/holidayapi'

const open = ref<boolean>(false);
const yearMonth = ref('')
const value = ref<boolean>(false)


//打开弹出框
const showModal = (value: any) => {
  yearMonth.value = value.format('YYYY-MM-DD')
  open.value = true;
};

const handleOk = () => {
  let input = {
    date: yearMonth.value,
    isHoliday: value.value
  }
  Holidayapi.UpdateDate(input).then(res => {
    console.log(res);
  })
  open.value = false;
  location.reload();
};

// 调用这个函数将子组件的一些数据和方法暴露出去
defineExpose({
  showModal
})
</script>
